package com.live.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.live.common.Constant;
import com.live.common.LiveCommon;
import com.live.task.LiveUser;
import com.live.tools.LiveTools;

public class LiveUserLoginActivity extends LiveBaseActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.user_login);

		// 设置头部信息
		LiveCommon.setHead(context, (LinearLayout) findViewById(R.id.liveHead), R.string.user_login,
				R.string.user_login_btn);

		// 用户登录按钮
		Button loginBtn = (Button) findViewById(R.id.headFuncBtn);
		loginBtn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				// 登录
				EditText userId = (EditText) findViewById(R.id.userId);
				EditText userPwd = (EditText) findViewById(R.id.userPwd);

				String url = Constant.SITE_URL + "live_user.php?locale=" + LiveTools.getLocaleLanguage()
						+ "&userDeviceId=" + deviceID + "&";
				url += "userId=" + userId.getText().toString() + "&userPwd=" + userPwd.getText().toString() + "&type=l";

				user.setUserId(userId.getText().toString());
				user.setUserPwd(userPwd.getText().toString());

				LiveUser task = new LiveUser(context, url, "登录");
				task.execute(user);
			}
		});

		// 用户注册按钮
		Button registBtn = (Button) findViewById(R.id.registBtn);
		registBtn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(context, LiveUserRegistActivity.class);
				context.startActivity(intent);
			}
		});
	}
}